{{!
    This file is part of Moodle - http://moodle.org/

    Moodle is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Moodle is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
}}
{{!
    @template mod_lti/tool_proxy_registration_form

    This template provides the registration form to submit an external
    LTI registration.

    Classes required for JS:
    * none

    Data attributes required for JS:
    * none

    Context variables required for this template:
    *

}}
<div id="tool-proxy-registration-form-container">
    <div class="registration-loading-container loading-screen">
        {{> mod_lti/loader }}
        <p class="loading-text">{{#str}} loadinghelp, moodle {{/str}}</p>
        <p id="registration-loading-failed" class="hidden">{{#str}} register_warning, mod_lti {{/str}}</p>
    </div>
    <iframe id="registration-page-iframe" name="registration-page-iframe" class="hidden">
    </iframe>
    <form action="{{{reg_url}}}" name="ltiLaunchForm" id="ltiLaunchForm" method="post" encType="application/x-www-form-urlencoded" target="registration-page-iframe">
        <input type="hidden" name="lti_message_type" value="{{lti_message_type}}" />
        <input type="hidden" name="lti_version" value="{{lti_version}}" />
        <input type="hidden" name="reg_key" value="{{reg_key}}" />
        <input type="hidden" name="reg_password" value="{{reg_password}}" />
        <input type="hidden" name="tc_profile_url" value="{{{tc_profile_url}}}" />
        <input type="hidden" name="launch_presentation_return_url" value="{{{launch_presentation_return_url}}}" />
    </form>
</div>
{{#js}}
    require(['jquery'], function($) {
        var loadingContainer = $('#tool-proxy-registration-form-container .registration-loading-container');
        var iframe = $('#registration-page-iframe');
        var timeout = setTimeout(function () {
            var failedContainer = $('#registration-loading-failed');
            failedContainer.removeClass('hidden');
        }, 20000);

        iframe.load(function() {
            loadingContainer.addClass('hidden');
            iframe.removeClass('hidden');
        });
    });
{{/js}}
